package com.example.system.controller;

import com.example.system.model.ApiResponse;
import com.example.system.service.SysBannerService;
import com.example.system.entity.SysBanner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * author: adnaan
 * create: 2023-11-02 08:23
 * Description:
 */
@RestController
@RequestMapping("/banner")
public class SysBannerController {

    @Autowired
    private SysBannerService sysBannerService;

    @RequestMapping("/view")
    public ApiResponse findByStatus() {
        return sysBannerService.findByStatus();
    }

    @GetMapping("/page")
    public ApiResponse findPage(@RequestParam Integer currentPage,
                                @RequestParam Integer pageSize
    ) {
        return sysBannerService.findPaginated(currentPage, pageSize);
    }

    @PostMapping("/addBanner")
    public ApiResponse addBanner(@RequestBody SysBanner banner){
        return sysBannerService.addBanner(banner);
    }

    @DeleteMapping("/delBanner")
    public ApiResponse delBanner(@RequestParam String bannerId){
        return sysBannerService.delBanner(bannerId);
    }

    @PutMapping("/updateBanner")
    public ApiResponse update(@RequestBody SysBanner banner){
        return sysBannerService.updateBanner(banner);
    }
}
